<?php

class Core_Action_Admin_System_Appearance_Section_Block_Index extends Action_Admin
{

	function initiator()
	{
		parent::initiator();

		Agilet::setVar(array(
			'page-title' => 'Design Block',
			'toolbar' => 'admin/system/appearance/section/block',
			'breadcrum' => array(
				array(
					'url' => 'admin/system',
					'label' => 'System'
				),
				array(
					'url' => 'admin/system/appearance',
					'label' => 'Appearance'
				),
				array(
					'url' => 'admin/system/appearance/section',
					'label' => 'Section'
				),
				array(
					'url' => 'admin/system/appearance/section/block',
					'label' => 'Design Block'
				),
			)
		));
	}

	public function execute($request, $initial = false, $script = null)
	{
		$table = Model::getTable('core/appearance/block');

		$section_id = intval($request -> getParam('section_id'));

		$select = $table -> select() -> where('section_id=?', $section_id) -> order('region') -> order('sort_order');

		$items = $table -> fetchAll($select);

		$request -> response = View::render($script = 'core/html/admin/system/appearance/section/block/index', $data = array('items' => $items));
	}

}
